package com.gongj.demo1;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.concurrent.*;

public class TestSimpleDateFormat {

    public static void main(String[] args) throws ExecutionException, InterruptedException, ParseException {
        final SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");

        //创建长度为10的线程池
        ThreadPoolExecutor threadPoolExecutor =
                new ThreadPoolExecutor(2, 5, 5, TimeUnit.SECONDS, new LinkedBlockingQueue(5));
        Callable<Date> callable = () -> format.parse("20201227");

        List<Future<Date>> list = new ArrayList<>();
        for (int i = 1; i <= 10; i++) {
            list.add(threadPoolExecutor.submit(callable));
        }
        for (Future<Date> dateFuture : list) {
            System.out.println(dateFuture.get());
        }

        threadPoolExecutor.shutdown();
    }
}
